<?php $this->load->module('mobile/index/header', $common);?>

<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/dialog.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/base.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/index.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/line.css" />
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/mobilecommon.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/slider.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/dialog.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/flight.css" />
    <div class="content">
    <section id="panel-box" class="pb85">
        <ul class="flight-srhform">
            <li class="flight-switch">
                <dl>
                    <dd class="flight-departcity j_touching">
                        <span id="js_departcity"><input type="text" name="scity" readonly value="<?php echo $scity ;?>" placeholder="出发城市" style="border-width:0; "></span></dd>
                    <dt class="flight-cityswitch j_touching" id="js_change">
                        切换<i class="icon-switch"><i class="s1"></i><i class="s2"></i><i class="s3"></i></i>
                    </dt>
                    <dd class="flight-backcity j_touching"
                        ><span id="js_backcity"><input type="text" name="ecity" readonly value="<?php echo $ecity ;?>" placeholder="到达城市" style="border-width:0; "> </span></dd>
                </dl>
            </li>

            <li class="city_tit_box">
                <dl class="startdate city_tit city_padding_left">
                    <dd id="js_departDate" class="flight-date j_touching">
                        <em><input type="date" name="sdate" style="border-width:0;width:100%;background: transparent " value="<?php echo date('Y-m-d',strtotime("+1 days"))?>"></em>

                    </dd>
                </dl>

            </li>

            <li>
                <button id="searchlistsubmit" class="flight-btnsrh j_touching">查&nbsp;询</button>
            </li>
        </ul>
        <div class="blk30"></div>
    </section>
        </div>
<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">

    <?php if(isset($_GET['preview'])||isset($_GET['touchtpl'])):?>
    var url  = '<?php echo site_url('mobile/flight/city?');?>&' ;
    <?php else:?>
    var url  = '<?php echo site_url('mobile/flight/city?');?>' ;
    <?php endif;?>

    function alert_popup(text){
        $.dialog({
            style:'tip',
            width:200,
            closeTime:1000,
            content: '<p style="text-align: center">'+text+'</p>'
        }).open();
    }

    $(function(){

        $('#js_departcity').click(function(){
            var str = 'isScity=1&' ;
            var scity = $('input[name="scity"]').val();
            var ecity = $('input[name="ecity"]').val();
            if(scity.length>0){
                var str = str+'scity='+ scity ;
            }
            if(ecity.length>0){
                var str = str+'&ecity='+ecity ;
            }
            window.location.href = url+''+str ;
        })
        $('#js_backcity').click(function(){
            var str = 'isEcity=1&' ;
            var scity = $('input[name="scity"]').val();
            var ecity = $('input[name="ecity"]').val();
            if(scity.length>0){
                var str = str+'scity='+ scity ;
            }
            if(ecity.length>0){
                var str = str+'&ecity='+ecity ;
            }

            window.location.href = url+''+str ;
        })

        $('#js_change').on('click',function(){
            var scity = $('input[name="scity"]').val();
            var ecity = $('input[name="ecity"]').val();
            if(scity.length>0&&ecity.length>0)
            {
                $('input[name="scity"]').val(ecity);
                $('input[name="ecity"]').val(scity);
            }

        });

        $('#searchlistsubmit').on('click',function(){

           var scity = $('input[name="scity"]').val();
           var ecity = $('input[name="ecity"]').val();
           var sdate = $('input[name="sdate"]').val();

            if(scity.length == 0){
                alert_popup('请选择出发城市');
                return false;
            }
            if(ecity.length == 0){
                alert_popup('请选择目的地城市');
                return false;
            }
            if(sdate.length == 0){
                alert_popup('请选择出发日期');
                return false;
            }
            $.dialog({
                style:'tip',
                width:200,
                closeTime:1000,
                content: '<p style="text-align: center">加载中...</p>'
            }).open();

            var flight_url = '<?php echo site_url('mobile/flight/flight_list?param=');?>';
            var url = flight_url+''+scity+'_'+ecity+'_'+sdate ;
            window.location.href = url ;
        })

    })
</script>
